import { isPhoneNumber } from '@/utils/index'

export const formRules = {
  name: [{ required: true, validator: notEmpty, msg: '请输入合同名称', trigger: ['change','blur'] }],
  number: [{ required: true, validator: notEmpty, msg: '请输入合同编号', trigger: ['change','blur'] }],
  amountWithTax: [{ required: true, validator: notEmpty, msg: '请输入合同含税金额', trigger: ['change','blur'] }],
  amountWithoutTax: [{ required: true, validator: notEmpty, msg: '请输入合同不含税金额', trigger: ['change','blur'] }],
  category: [{ required: true, validator: notEmpty, msg: '请选择合同类别', trigger: ['change','blur'] }],
  type: [{ required: true, validator: notEmpty, msg: '请选择合同类型', trigger: ['change','blur'] }],
  department: [{ required: true, validator: notEmpty, msg: '请选择所属部门', trigger: ['change','blur'] }],
  contractTime: [{ required: true, validator: notEmpty, msg: '请选择合同时间', trigger: ['change','blur'] }],
}



// 校验不能为空
function notEmpty(rule, value, callback) {
  if (!value) {
    if (rule.field === 'category' && value === 0) {
      return callback()
    }
    return callback(new Error(rule.msg))
  }else{
    return callback()
  }
}



export const companiesColumn = [
  { prop: 'name', label: '单位名称', align: 'center', },
  { prop: 'type', label: '单位类型', align: 'center'},
  { prop: 'creditCode', label: '信用代码', align: 'center'},
  { prop: 'contactPerson', label: '联系人', align: 'center'},
  { prop: 'phone', label: '联系电话', align: 'center'},
]


export const relationsColumn = [
  { prop: 'name', label: '合同名称', align: 'center', },
  { prop: 'number', label: '合同编号', align: 'center', width: 160},
  { prop: 'category', label: '合同类别', align: 'center'},
  { prop: 'type', label: '合同类型', align: 'center'},
  { prop: 'department', label: '所属部门', align: 'center'},
  { prop: 'amountWithTax', label: '合同金额（含税）', align: 'center', width: 180, type: 'number'},
  { prop: 'amountWithoutTax', label: '合同金额（不含税）', align: 'center', width: 180, type: 'number'},
]

